<?php
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2002-2005 Fr&eacute;d&eacute;ric Descamps <lefred@tiscali.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

if($_GET['id']) $id=$_GET['id'];
else $id=$_POST['id'];
$sw=$_POST['sw'];

if(!$id)
{
        $requete = "select * from classes order by classe";
        if(!($resultat = biblio_db_query($requete)))
        { print "PROBLEME : " .biblio_db_error(); }
        else 
        {
                echo "<CENTER><H3>";
		echo _("Modifier une classe");
		echo "</H3>";
                echo "<TABLE><TR><th>Classe</th><th>Action</th>";
        
                while ($row = biblio_db_fetch_array($resultat)) 
	        {      
                        $classe_id = $row['id'];           
                        $classe_nom =  $row['classe'];                                
                        echo "<TR><TD>$classe_nom</TD><TD><A href=\"admin.php?action=mod&type=classe&id=$classe_id\"><IMG SRC=\"images/wh_r_arr.gif\" ALT=\"";
			echo _("changer");
			echo "\" border=0 align=right></A></TD>";            
                }
                echo "</TABLE></CENTER>";
        }
}
else
{
    if ($sw!=1)
    {
 
       $requete = "select * from classes where id=$id";
        if(!($resultat = biblio_db_query($requete)))
        { print "PROBLEME : " .biblio_db_error(); }
        else 
        {
                while ($row = biblio_db_fetch_array($resultat)) 
	        {      
                        $classe_id = $row['id'];           
                        $classe_nom =  $row['classe'];      
                }
         }
        ?>
        <CENTER><H3>
	<?php echo _("Modifier la classe"); ?>
	</H3>
        <I>
	<?php echo _("Tous les &eacute;l&egrave;ves &eacute;tant dans cette classe seront modifi&eacute;s en cons&eacute;quence..."); ?>
	</I><BR><BR>
        <FORM action=admin.php METHOD=POST>
        <TABLE BORDER=0>
        <TR>
        <TD>
	<?php echo _("Classe"); ?>
	:</TD><TD><INPUT TYPE="text" NAME="classe" size = 20 value="<?php echo $classe_nom; ?>"></TD>
        <TR>
        </TABLE><BR>
        <INPUT TYPE="hidden" NAME="user" value="<?php echo $user; ?>">
        <INPUT TYPE="hidden" NAME="action" value="<?php echo $action; ?>">
        <INPUT TYPE="hidden" NAME="type" value="<?php echo $type; ?>">
        <INPUT TYPE="hidden" NAME="sw" value="1">
        <INPUT TYPE="hidden" NAME="id" value="<?php echo $id; ?>">        
        <input type="Submit" value="Enregistrer">
        </FORM>
        </CENTER>
        <?php
    }   
    else
    {
      $classe=$_POST['classe'];
      $requete = "update classes set classe='$classe' where id=$id";
      if(!($resultat = biblio_db_query($requete)))
      { echo "PROBLEME : " .biblio_db_error(); exit;}  
      put_log(3,$requete,$user); 
      echo "<CENTER><BR>";
      echo _("La classe a &eacute;t&eacute; modifi&eacute;e comme : <b>$classe</b>.");
      echo "<br></center>";
    } 
}
?>
<br><br>
<div>
<span id=left-text>
<A HREF="admin.php?menu=1">
<?php echo _("retour menu administration"); ?>
</A><BR>
<A HREF="index.php">
<?php echo _("retour menu principal"); ?>
</A></span>
</div>
<br>

